# Replication package for: The appendix to Trade-Policy Dynamics: Evidence from 60 Years of U.S.-China Trade
Alessandria,  Khan, Khederlarian, Ruhl, and Steinberg

## 1 Data

All data used in this project are publicly available.

The data used are included in this replication package to guard against revisions to data making replication difficult. Links to the data sources and their sources are in `Docs/`.

## 2 Replication

There are three main parts of the replication: 

1. Data preparation and the regression models 
2. The structural model (which uses output of the regression models) 
3. Creation of  figures, tables, and numbers in the text (which uses output of the regression models and the structural models)

The three parts are described below and need to be replicated in the order presented. 

### 2.1 Data preparation and reduced-form modeling
The nature of STATA requires reading and writing to the hard disk often. Turning off syncing applications (e.g., Dropbox) may be necessary.

#### Requirements
* STATA and packages
	* egenmore
	* unique
	* estout
	* reghdfe
	* ftools
	* ivreghdfe
	* ivreg2
	* ranktest

Execute "00 run all files.do", or run, in this order:

* "01 preliminaries.do"
* "02 create tsusa hts concordance.do"
* "03 create tsusa dataset.do"
* "04 create hs8 dataset.do"
* "05 create tsushts dataset.do"
* "06 create world dataset.do"
* "10 appendix tables.do"
* "20 appendix figures.do"

All files are in "13 Code appendix"

### 2.2 Structural model

#### Requirements
* At least 20 processing cores, but 60+ for reasonable running times
* Python 3 and packages
	* numpy
	* scipy
	* matplotlib
	* statsmodels
	* seaborn
* gcc C compiler
* OpenMP library
* GSL library

See the readme file in `11 Code structural model` for details and instruction. 

### 2.3 Final output creation

### Requirements
* python3 and packages
	* jupyter notebook 
	* pandas
	* numpy
	* matplotlib
	* statsmodels
	* math

Run, in order  

* 10 tables.ipynb
* 20 figures.ipynb
 
Both files are in `13 Code appendix`.

# 3 Tables and figures
When created, tables and figures are saved in `31 Final output files appendix`.

| Exhibit | Created in | File name|
|---------|------------|----------|
|Table G1| 12 Code final outputs/10 tables.ipynb|tableG1.tex|
|Table G2| Recreated from Xie et al. (2020)|main.tex|
|Table G3| 13 Code appendix/10 tables.ipynb|tableG3.tex|
|Table G4| 13 Code appendix/10 tables.ipynb|tableG4.tex|
|Table G5| 13 Code appendix/10 tables.ipynb|tableG5.tex|
|Table G6| 13 Code appendix/10 tables.ipynb|tableG6.tex|
|Table G7| 13 Code appendix/10 tables.ipynb|tableG7.tex|
|Table G8| 13 Code appendix/10 tables.ipynb|tableG8.tex|
|Table G9| 12 Code final outputs/ |tableG9.tex|
|Figure H1|13 Code appendix/20 appendix figures.do|figH1.pdf|
|Figure H2|13 Code appendix/20 appendix figures.do|figH2.pdf|
|Figure H3|13 Code appendix/20 appendix figures.do|figH3.pdf|
|Figure H4|13 Code appendix/20 appendix figures.do|figH4.pdf|
|Figure H5|13 Code appendix/20 appendix figures.do|figH5.pdf|
|Figure H6|13 Code appendix/20 appendix figures.do|figH6.pdf|
|Figure H7|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H8|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H9|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H10|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H11|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H12|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H13|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H14|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H15|13 Code appendix/20 figures.ipynb|figH7.pdf|
|Figure H16|13 Code appendix/20 appendix figures.do|figH16.pdf|
|Figure H17|13 Code appendix/20 appendix figures.do|figH17.pdf|
|Figure H18|13 Code appendix/20 appendix figures.do|figH18.pdf|
|Figure H19|13 Code appendix/20 appendix figures.do|figH19.pdf|
|Figure H20|13 Code appendix/20 appendix figures.do|figH20.pdf|

